class ListNode:
    def __init__(self, x):
        if len(x) > 1:
            self.val = x[0]
            self.next = ListNode(x[1::])
        else:
            self.val = x[0]
            self.next = None
